<!DOCTYPE HTML>
<html style="background-color:rgb(249,249,251)">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Activities</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" href="../css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/index.css">
</head>
<style>
    [v-cloak] {
        display: none;
    }
</style>

<body style="background-color:#fff">

    <!-- rgb(249,249,251) -->
    <section class="aui-content" style="width:95%;margin:auto;padding-bottom:0rem;">

        <div class="van-notice-bar" style="background: #ffffff">
            <div class="van-notice-bar__left-icon"><img src="../icon/voice.png"></div>
            <div class="van-notice-bar__wrap">
                <div class="van-notice-bar__content van-ellipsis" style="padding-left: 0px; animation-delay: 1s; animation-duration: 0s;">&nbsp;&nbsp;&nbsp;&nbsp;双击活动可以删除哦</div>
            </div>
        </div>

        <div class="aui-card-list" v-cloak style="margin-top:-0.5rem">
            <div class="aui-card-list-content-padded">
                <div class="aui-content" id="demo">
                    <ul class="aui-list aui-media-list">
                        <li class="aui-list-item" v-for="item in activities">
                            <div class="aui-media-list-item-inner" @dblclick="del($index)">
                                <div class="aui-list-item-media" style="width:5rem;height:4.0rem" @click="changetoAD($index)">
                                    <img :src="item.imagearray[0]" style="width:100%;height:100%">
                                </div>
                                <div class="aui-list-item-inner">
                                    <div class="aui-list-item-text" @click="changetoAD($index)">
                                        <div class="aui-list-item-title">{{item.title}}</div>
                                        <div class="aui-list-item-right">{{item.time}}</div>
                                        <!-- 走进课堂 -->
                                    </div>
                                    <div class="aui-list-item-text" @click="changetoAD($index)">
                                        {{item.type}}
                                    </div>
                                    <!-- 超级管理员01 -->
                                    <div class="aui-info" style="padding:0rem;padding-right:1rem;">
                                        <i class="fa fa-thumbs-o-up" aria-hidden="true" style="color:#757575" @click="prase($event,$index)">{{item.parsecount}}</i>
                                        <i class="fa fa-star-o" aria-hidden="true" style="left:3%;color:#757575" @click="store($event,$index)">{{item.storecount}}</i>
                                        <i class="fa fa-commenting-o" aria-hidden="true" style="left:5%" @click="comment($index)">
                                            {{item.commentcount}}</i>
                                    </div>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/aui-slide.js"></script>
<script type="text/javascript" src="../script/vue1.0.js"></script>
<script type="text/javascript" src="../script/util.js"></script>
<script type="text/javascript" src="../script/common1.js"></script>
<script type="text/javascript" src="../script/constant.js"></script>
<script type="text/javascript" src="../script/vant.min.js"></script>
<script type="text/javascript">
    // var pclickcount = 0;
    var ptype = 0;
    var cclickcount = 0;
    var ptype = "";
    var stype = "";
    //设置延时单击
    var clickTimeId;
    apiready = function () {
        var length = 0;
        var count = 0;
        vm = new Vue(vueConfig)
        api.setCustomRefreshHeaderInfo({
            bgColor: '#f0f0f0',
            image: {
                pull: 'widget://image/pull.png',
                transform: [
                    'widget://image/pull_end_image_frame_01.png',
                    'widget://image/pull_end_image_frame_02.png',
                    'widget://image/pull_end_image_frame_03.png',
                    'widget://image/pull_end_image_frame_04.png',
                    'widget://image/pull_end_image_frame_05.png'
                ],
                load: [
                    'widget://image/refreshing_image_frame_01.png',
                    'widget://image/refreshing_image_frame_02.png',
                    'widget://image/refreshing_image_frame_03.png',
                    'widget://image/refreshing_image_frame_04.png',
                    'widget://image/refreshing_image_frame_05.png',
                    'widget://image/refreshing_image_frame_06.png'
                ]
            }
        }, function () {
            vm.count = 0;
            vm.get(1);
            downFresh = true;
            api.refreshHeaderLoadDone();
        });
        var downFresh = false;
        //上拉加载
        api.addEventListener({
            name: 'scrolltobottom',
            extra: {
                threshold: 0
            }
        }, function (ret, err) {
            if (vm.ifcount == 8) {
                vm.count = vm.count + 8;
                vm.get(2);
            }
        });
    };
    var vueConfig = {
        el: "body",
        data: {
            activities: [],
            x: 0,
            styles: {
                color: "red"
            },
            state: false,
            count: 0,
            ifcount: 8

        },
        methods: {
            changetoAD: function (index) {
                clearTimeout(clickTimeId);
                clickTimeId = setTimeout(function () {
                    api.openWin({
                        name: 'ActivitiesDetails',
                        url: './activityList/ActivitiesDetails.html',
                        pageParam: {
                            index: index,
                            type: 2
                        }
                    });
                }, 250);
            },
            //点赞
            prase: function (ev, index) {},
            //收藏
            store: function (ev, index) {},
            //评论
            comment: function () {
                var me = this;
            },
            changeState: function () {
                downFresh = false;
            },
            //删除
            del: function (index) {
                var me = this;
                clearTimeout(clickTimeId);
                api.confirm({
                    title: '删除活动',
                    buttons: ['确定删除', '取消']
                }, function (ret, err) {
                    var index1 = ret.buttonIndex;
                    if (index1 == 1) {
                        api.ajax({
                            url: serverIp + '/friend/multiDelActivity.do',
                            method: 'post',
                            data: {
                                values: {
                                    ids: me.activities[index].oid
                                }
                            }
                        }, function (ret, err) {
                            if (ret) {
                                if (ret.success) {
                                    api.hideProgress();
                                    api.alert({
                                        title: '提示',
                                        msg: '删除成功',
                                    }, function (ret, err) {});
                                    me.get();
                                } else {
                                    alert("error");
                                }
                            }
                        });
                    }
                });
            },
            get: function (x) {
                var me = this;
                //代表刷新
                if (x == 1) {
                    me.activities = [];
                    api.ajax({
                        url: serverIp + '/friend/listMyForAppActivity.do',
                        method: "post",
                        data: {
                            values: {
                                count: me.count
                            }
                        }
                    }, function (ret, err) {
                        if (ret) {
                            me.ifcount = ret.length;
                            if (ret.length < 8) {
                                api.hideProgress();
                            }
                            if (me.ifcount == 0) {
                                section = $api.byId('section');
                                var str =
                                    "<div style='width:100%;height:10rem;margin:0 auto;margin-top:1rem;'><img src='../image/nothing.gif'  style='width:100%;height:100%'></div>"
                                $api.prepend(section, str);
                            }
                            for (var i = 0; i < me.ifcount; i++) {
                                me.activities.push(ret[i]);
                            }
                            for (var i = 0; i < me.ifcount; i++) {
                                var imagearray = ret[i].imagePaths.split(',');
                                me.activities[i].imagearray = imagearray;
                            }
                            api.setPrefs({
                                key: 'activities1',
                                value: me.activities
                            });
                            api.hideProgress();
                        } else {
                            alert(err);
                            api.hideProgress();
                        }
                    });
                }
                //下拉加载
                else {
                    if (me.ifcount == 8) {
                        api.showProgress({
                            style: 'default',
                            title: '努力加载中...',
                            text: '先喝杯茶...',
                            modal: false
                        });
                    }
                    api.ajax({
                        url: serverIp + '/friend/listMyForAppActivity.do',
                        method: "post",
                        data: {
                            values: {
                                count: me.count
                            }
                        }
                    }, function (ret, err) {
                        api.hideProgress();
                        if (ret) {
                            me.ifcount = ret.length;
                            if (ret.length < 8) {
                                api.hideProgress();
                            }
                            if (me.ifcount == 0) {
                                section = $api.byId('section');
                                var str =
                                    "<div style='width:100%;height:10rem;margin:0 auto;margin-top:1rem;'><img src='../image/nothing.gif'  style='width:100%;height:100%'></div>"
                                $api.prepend(section, str);
                            }
                            for (var i = 0; i < me.ifcount; i++) {
                                me.activities.push(ret[i]);
                            }
                            for (var i = me.count, j = 0; i < me.ifcount + me.count; i++, j++) {
                                var imagearray = ret[j].imagePaths.split(',');
                                me.activities[i].imagearray = imagearray;
                            }
                            api.setPrefs({
                                key: 'activities1',
                                value: me.activities
                            });
                        } else {
                            alert(err);
                        }
                    });
                }
            }
        },
        created: function () {
            var me = this;
            me.get();
        }
    };
</script>

</html>